<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://lib.baomitu.com/jquery/3.6.0/jquery.js"></script>
    <script src='./dist/include-openlayers-local.js'></script>
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        #map {
            height: 100vh;
            width: 100vw;
        }
        span {
            position: fixed;
            width: 200px;
            height: 100px;
        }

        #vectors {
            bottom: 30px;
            right: 300px;
            background-color: pink;
        }

        #image {
            bottom: 30px;
            right: 50px;
            background-color: skyblue;
        }
    </style>
</head>
<body>
    <div id="map"></div>
    <span id="vectors"></span>
    <span id="image"></span>

    <script>
        var gaodeMapLayer = new ol.layer.Tile({
            title: "高德地图矢量图层",
            source: new ol.source.XYZ({
                url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
                wrapX: false
            })
        });

        var image = new ol.layer.Tile({
            title: "高德地图影像图层",
            source: new ol.source.XYZ({
                url: "http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=6&x={x}&y={y}&z={z}",
                wrapX: false
            })
        })

        var zhuji = new ol.layer.Tile({
            title: "高德地图影像注记图层",
            source: new ol.source.XYZ({
                url: "http://webst02.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8",
                wrapX: false
            }) 
        })

        let map = new ol.Map({
            target:'map',
            layers: [gaodeMapLayer,image,zhuji],
            view: new ol.View({
                center: [12958752, 4848452],
                projection: 'EPSG:3857',
                zoom: 5,
            })
        })

        // 实现点击删除
        let layers = map.getLayers().getArray() 
        $('#image').click(function() {
            layers[1].setVisible(true)
            layers[2].setVisible(true)
        })

        $('#vectors').click(function() {
            layers[1].setVisible(false)
            layers[2].setVisible(false)
        })


        // 矢量小图

        let mapVectors = new ol.Map({
            target:'vectors',
            layers: [gaodeMapLayer],
            view: new ol.View({
                center: [12958752, 4848452],
                projection: 'EPSG:3857',
                zoom: 5,
            })
        })


        // 影像小图

        var Simage = new ol.layer.Tile({
            title: "高德地图影像图层",
            source: new ol.source.XYZ({
                url: "http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=6&x={x}&y={y}&z={z}",
                wrapX: false
            })
        })

        var Szhuji = new ol.layer.Tile({
            title: "高德地图影像注记图层",
            source: new ol.source.XYZ({
                url: "http://webst02.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8",
                wrapX: false
            }) 
        })




        let mapImage = new ol.Map({
            target:'image',
            layers: [Simage,Szhuji],
            view: new ol.View({
                center: [12958752, 4848452],
                projection: 'EPSG:3857',
                zoom: 5,
            })
        })

    </script>
</body>
</html>